<%--
  Created by IntelliJ IDEA.
  User: qjqe@outlook.com
  Date: 2020/5/15
  Time: 9:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@page import="java.util.List"%>
<script>
    /*修改
    点击之后页面变成可提交状态*/
    function chengji(a){
        var trobj = a.parentNode.parentNode; //获得按钮所在行的行对象
        var tdobj = trobj.getElementsByTagName("td");
        for(var i =2;i<tdobj.length-2;i++){
            tdobj[i].innerHTML = "<input class='edit" + i + "'  style='max-width: 100px;' onblur='submit()' type=\"input\" value=" + tdobj[i].innerText + "  />";
        }
        //tdobj.innerHTML = "<input class='edit"  + "'  style='max-width: 100px;' onblur='submit()' type=\"input\" value=" +  "  />";
    }
    //修改后提交功能
    //异步提交
    function submit(){
        var fenshu=$(".edit2").val();
        var xueshengid=$("#xueshengbianhao").text();
        //alert(xueshengid);
        var kechengbianhao=$("#kechengbianhao").text();

        $.ajax(
            {
                url: "/markman/add",
                type: "post",
                datatype:"json",
                data:{"fenshu":fenshu,"xueshengid": xueshengid,"kechengbianhao":kechengbianhao},
                success: function (result) { //返回的结果自动放在resut里面了
                    if (result.status == "success") {//请求成功
                        alert("成功");
                        location.reload();
                    } else {
                        alert("失败");
                        location.reload();
                    }
                }
            });
    }

    //重新刷新
    function reload() {
        location.reload();
    }
    function choessc(a){
        //$("#report").css("display","none");
        //$("#form").attr('style','display:inline')


        $.ajax(
            {
                url: "/course/choess",
                type: "post",
                datatype:"json",
                data:{"id":a},
                success: function (result) { //返回的结果自动放在resut里面了
                    if (result.status == "success") {//请求成功
                        alert("成功");
                        location.reload();
                    } else {
                        alert("失败");
                        location.reload();
                    }
                }
            });
    }


</script>
<div id="report">
    <h2 class="sub-header">成绩列表</h2>
    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
            <tr>
                <th>学生名字</th>
                <th>课程名字</th>
                <th>课程成绩</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items = "${requestScope.zhanshiList }" var="zhanshiList">
                <tr>
                    <td >${zhanshiList.studengname }</td>
                    <td >${zhanshiList.kechengname}</td>
                    <td >${zhanshiList.chengji }</td>
                    <td><p id="kechengbianhao" style="display: none">${zhanshiList.courseid}</p></td>
                    <td><p id="xueshengbianhao" style="display: none">${zhanshiList.xueshengid}</p></td>
                    <th><button class="btn btn-default delete" onclick="chengji(this)">打分</button></th>



                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
